package cate.game.play.skill.passive.hero;

import cate.common.table.d.GDSkill;
import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.TimeActionCtx;
import cate.game.play.proce.move.AppendMove;
import cate.game.play.proce.move.MoveCtx;
import cate.game.play.skill.Skill;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 攻击时60%追加一次圣罚，造成120%物理伤害/n无冷却时间
 */
public class 圣剑压制PH extends PassiveHandler {

	private int 概率;

	private int 追加技能;

	//概率=6000&追加技能=？？
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		追加技能 = args.getInt("追加技能", 0);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 += args.getInt("概率", 0);
	}

	@Override
	public void onOwnerMoveDone(MoveCtx move, TimeActionCtx action) {
		if(move.isAppend()){
			return;
		}
		if(!move.getSkill().cfg.isEffectType(GDSkill.EffectType.伤害)){
			return;
		}
		if(!XT.chance(概率)){
			return;
		}
		Skill appendSkill = move.getCfg().skill.buildById(this.skill.owner, 追加技能);
		if (appendSkill == null) {
			return;
		}
		move.getTurn().addAppend(new AppendMove(skill.owner, appendSkill));
	}
}
